package com.ruoyi.fly.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fly.domain.Vehicles;
import com.ruoyi.fly.domain.vo.DeleteVo;
import com.ruoyi.fly.domain.vo.Examine;
import com.ruoyi.fly.domain.vo.VehiclesUpdateVo;
import com.ruoyi.fly.domain.vo.VehiclesVo;
import com.ruoyi.fly.service.VehiclesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆信息Controller
 * @date 2024-04-25
 */
@RestController
@RequestMapping("/vehicles")
@Api(tags = "车辆管理")
public class VehiclesController extends BaseController {
    @Autowired
    private VehiclesService vehiclesService;

    /**
     * 查询车辆信息列表
     */
    @ApiOperation(value = "查询车辆信息列表")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody Vehicles vehicles) {
        startPage();
        List<VehiclesVo> list = vehiclesService.selectPcVehiclesList(vehicles);
        return getDataTable(list);
    }


    /**
     * 根据车辆id获取车辆信息
     */
    @ApiOperation(value = "根据车辆id获取车辆信息")
    @GetMapping(value = "/select/{id}")
    public R getInfo(@PathVariable("id") String id) {
        return R.ok(vehiclesService.selectPcVehiclesById(id));
    }

    /**
     * 增加车辆
     */
    @ApiOperation(value = "增加车辆")
    @PostMapping("/add")
    public R add(@RequestBody VehiclesVo vehiclesVo) {
        return vehiclesService.insertPcVehicles(vehiclesVo);
    }


    /**
     * 修改车辆信息
     */
    @ApiOperation(value = "修改车辆信息")
    @PostMapping("/edit")
    public R edit(@RequestBody VehiclesUpdateVo vehiclesUpdateVo) {
        return vehiclesService.updatePcVehicles(vehiclesUpdateVo);
    }

    /**
     * 删除车辆信息
     */
    @ApiOperation(value = "删除车辆信息")
    @PostMapping("/delete/{ids}")
    public R remove(@PathVariable DeleteVo deleteVo) {
        return vehiclesService.deletePcVehiclesByIds(deleteVo.getIds());
    }
}
